'use strict';

import React,{Component} from 'react';
import {
  Dimensions,
  Text,
  InteractionManager,
  View,
  Image,
} from 'react-native';

import AppMain from './AppMain';

var {height, width} = Dimensions.get('window');
import ImgConifg from '../configs/ImgConfig';

class Splash extends Component{
  constructor(props){
    super(props);
  }

  componentDidMount(){
    const {navigator} = this.props;
         this.timer=setTimeout(() => {
          InteractionManager.runAfterInteractions(() => {
            navigator.resetTo({
              component: AppMain,
              name: 'AppMain'
            });
          });
        }, 2000);
  }

  componentWillUnmount(){
    this.timer && clearTimeout(this.timer);
  }

  render(){
    return(
      <View style={{flex:1}}>
        <Image
            style={{flex:1,width:width,height:height}}
            source={{uri:ImgConifg.SplashBackground}}
          />
      </View>
    );
  }
}

export default Splash;
